from django.db import models


# Create your models here.

class UserModel(models.Model):
    username = models.CharField(max_length=30)
    password = models.CharField(max_length=130)
    phone = models.CharField(max_length=11)
    img = models.ImageField(upload_to='static/img', null=True, blank=True)

    class Meta:
        db_table = 'user'

    def __str__(self):
        return self.username


class UserInfoModel(models.Model):
    email = models.EmailField(max_length=60)
    sex = models.CharField(max_length=20)
    age = models.CharField(max_length=20)
    site = models.CharField(max_length=100, verbose_name='地址')
    x_site = models.CharField(max_length=300, verbose_name='详细地址')
    user = models.ForeignKey(UserModel, on_delete=models.CASCADE)

    class Meta:
        db_table = 'userinfo'

    def __str__(self):
        return self.site
